package com.haoshuang.zhouzhoubang.ui.page.welfare.insure.record

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.InsureApplyRecordBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class InsureApplyRecordViewModel : BaseViewModel() {
    /**
     * 获取保险申请记录
     */
    val getInsureApplyRecordData = StatefulMutableLiveData<MutableList<InsureApplyRecordBean>>()
    fun getInsureApplyRecord(page: Int) = netRequest {
        start { getInsureApplyRecordData.value = StateData.Loading }
        request { ApiRepo.getInsureApplyRecord(page) }
        success { getInsureApplyRecordData.value = StateData.Success(it.data) }
        error { code, msg ->
            getInsureApplyRecordData.value = StateData.Error(code, msg)
        }
    }
}